<template>
	<view class="popup spec" v-show="spaceInfo.showSpace" @tap="hideSpecifications">
		<!-- 遮罩层 -->
		<view class="mask"></view>
		<view class="layer">
			<view class="content">
				<view class="title">选择规格：</view>
				<view class="sp">
					<view @tap.stop="handleSelectSpecification(item)" v-for="(item,index) in goodsData.spec" :class="{'on': item == goodsInfo.spec}"  :key="index">{{item}}</view>
				</view>
				<view class="length">
					<view class="text">数量</view>
					<counter :goodsInfo="goodsInfo"></counter>
				</view>
			</view>
			<view class="btn">
				<view class="button" @tap="hideSpecifications">确定</view>
			</view>
		</view>
	</view>
</template>

<script>
	import counter from './counter.vue'
	
	export default {
		props:{
			goodsData:Object,
			spaceInfo:Object,
			goodsInfo:Object
		},
		components: {
			counter
		},
		methods:{
			hideSpecifications() {
				this.spaceInfo.showSpace =false
			},
			handleSelectSpecification(item) {
				// 选择规格
				this.goodsInfo.spec = item
			}
		}
	}
</script>

<style lang="scss">
.popup {
	width: 100%;
	height: 100%;
	position: fixed;
	top: 0;
	z-index: 20;
	
	.mask{
		width: 100%;
		height: 100%;
		position: fixed;
		top: 0;
		z-index: 21;
		background-color: rgba(0, 0, 0, 0.6);
	}
	
	.layer {
		width: 92%;
		height: 70%;
		padding: 0 4%;
		display: flex;
		align-content: space-between;
		flex-wrap: wrap;
		position: fixed;
		bottom: 0;
		z-index: 22;
		border-radius: 20rpx 20rpx 0 0;
		background-color: #fff;
		
		.content {
			width: 100%;
			padding: 20rpx 0;
		}
		
		.btn {
			width: 100%;
			height: 100rpx;
		
			.button {
				width: 100%;
				height: 80rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				border-radius: 40rpx;
				color: #fff;
				background-color: #f47952;
				font-size: 28rpx;
			}
		}
	}
	
	&.spec {
		.title {
			margin: 30rpx 0;
			font-size: 30rpx;
		}
		.sp {
			display: flex;
			view {
				padding: 5rpx 20rpx;
				margin: 0 30rpx 20rpx 0;
				font-size: 28rpx;
				border-radius: 8rpx;
				background-color: #f6f6f6;
				&.on {
					padding: 3rpx 18rpx;
					border: solid 1rpx #f47925;
				}
			}
		}
		
		.length{
			padding-top: 20rpx;
			margin-top: 30rpx;
			border-top: solid 1rpx #aaa;
			display: flex;
			justify-content: space-between;
			align-items: center;
			border-top: solid 1rpx #aaa;
			
			.text{
				font-size: 30rpx;
			}
			
		}
		
	}
}	
</style>
